package day06;

import java.nio.file.*;

public class Demo09 {
    public static void main(String[] args) {
        /*
         * 文件复制功能
         * Path 和 File 作用类似
         * FileSystems: 文件系统, 就是Windows
         */
        // "F:\kafka_2.13-2.4.1.tgz"
        Path file1 = FileSystems.getDefault()
                .getPath("F:", "kafka_2.13-2.4.1.tgz");
        System.out.println("源文件:"+file1);
        Path file2 = FileSystems.getDefault()
                .getPath("F:", "demo.tgz");
        System.out.println("目标文件:"+file2);
        //StandardCopyOption 标注复制选项
        //REPLACE_EXISTING 如果存在就替换
        try {
            Files.copy(file1, file2, StandardCopyOption.REPLACE_EXISTING);
            System.out.println("复制成功");
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("复制失败");
        }
    }
}
